//
//  PTYScrollView.m
//  Communique
//
//  Created by Thomas Garrood on 15/09/2008.
//  Copyright 2008 __MyCompanyName__. All rights reserved.
//

#import "PTYScrollView.h"

@implementation PTYScrollView

- (id)initWithFrame: (NSRect) aRect
{
    self = [super initWithFrame: aRect];
    [self setAutoresizingMask: NSViewWidthSizable|NSViewHeightSizable];
    [self setHasVerticalScroller:YES];
    [self setHasHorizontalScroller:NO];
    
    [[NSNotificationCenter defaultCenter] addObserver:self
				selector:@selector(frameChanged:)
				name:NSViewFrameDidChangeNotification
				object:self];
    
    return self;
}

- (void) setDelegate:(PTYSession*)delegateIn 
{
	if (_delegate!=nil)
		[_delegate release];
	
	_delegate = delegateIn;
}

- (PTYSession*)delegate {
	return _delegate;
}

- (void)frameChanged:(NSNotification*)notification
{
	// SNG - hack to prevent this getting caught in a loop
	if (!_inFrameChanged)
    {
        _inFrameChanged = YES;
        [[self delegate] scrollViewResized: self];
        _inFrameChanged = NO;
    }
	//NSLog (@"%@", [[self contentView] frame]);
}

@end
